package com.topisv.tms.mybatis;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.ResultHandler;
import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;
import org.springframework.stereotype.Component;

/**
 * mybatis DAO共通工具
 * @author Fisher
 * @version 1.0.0
 */
//@Component
public class SqlMapDao extends SqlSessionDaoSupport {
    
    public Object selectOne(String statement) {
        return this.getSqlSession().selectOne(statement);
    }
    
    public Object selectOne(String statement, Object parameter) {
        return this.getSqlSession().selectOne(statement, parameter);
    }
    
    public Map selectMap(String statement, String mapKey) {
        return this.getSqlSession().selectMap(statement, mapKey);
    }
    
    public Map selectMap(String statement, Object parameter, String mapKey) {
        return this.getSqlSession().selectMap(statement, parameter, mapKey);
    }
    
    public Map selectMap(String statement, Object parameter, String mapKey, RowBounds rowBounds) {
        return this.getSqlSession().selectMap(statement, parameter, mapKey, rowBounds);
    }
    
    public List selectList(String statement) {
        return this.getSqlSession().selectList(statement);
    }
    public List selectList(String statement, Object parameter) {
        return this.getSqlSession().selectList(statement, parameter);
    }
    
    /**
     * 查询翻页的记录
     * @param 获取sql语句字符串
     * @param parameter 参数对象
     * @param rowBounds 翻页对象
     * @return 返回查询列表
     * @author Fisher
     * @version 1.0.0
     */
    public List selectList(String statement, Object parameter, RowBounds rowBounds) {
        return this.getSqlSession().selectList(statement, parameter, rowBounds);
    }
    
    public void select(String statement, ResultHandler handler) {
        this.getSqlSession().select(statement, handler);
    }
    
    public void select(String statement, Object parameter, ResultHandler handler) {
        this.getSqlSession().select(statement, parameter, handler);
    }
    
    public void select(String statement, Object parameter, RowBounds rowBounds, ResultHandler handler) {
        this.getSqlSession().select(statement, parameter, rowBounds, handler);
    }
    
    public void insert(String statement, Object parameter) {
        this.getSqlSession().insert(statement, parameter);
    }
    
}
